package service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import dao.LoverDao;
import dao.impl.LoverDaoImpl;
import domain.Lover;
import domain.User;

import java.util.List;

public class LoverService {
    String valueAsString = null;
    private LoverDao loverdao = new LoverDaoImpl();

    //用户喜爱度统计
    public String ToJson5(User user) {
        String telephone = user.getTelephone();
        List<Lover> list = loverdao.SelectLoverByTelephone(telephone);
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            valueAsString = objectMapper.writeValueAsString(list);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return valueAsString;
    }
}
